package org.aerie.forest.core.frame.rebar;

import java.util.ArrayList;
import java.util.List;

import org.aerie.forest.core.brick.exception.custom.runtime.SingletonInterceptException;

/**
 * @description forestSingleFrame单例校验容器
 *
 * @author quark
 * @organization aerie
 * @date 2020-8-14 14:08:21
 * @version 2.0.1
 */
enum SingletonValidateContainer {

	/**
	 * @description 单例
	 * 
	 * @author quark
	 * @date 2020-8-14 14:11:18
	 * @version 2.0.1
	 */
	INSTANCE;

	/**
	 * @description zhangqi
	 * 
	 * @author quark
	 * @date 2020-8-14 14:13:09
	 * @version 2.0.1
	 */
	private List<Class<? extends AbstractForestSingleFrame>> zhangQi = new ArrayList<>();

	/**
	 * @description 校验单例
	 * @param zClass 被校验的类
	 * @return 校验的结果
	 *
	 * @author quark
	 * @date 2020-8-14 14:17:16
	 * @version 2.0.1
	 */
	synchronized void checkSingleton(Class<? extends AbstractForestSingleFrame> zClass) {
		if (zhangQi.stream().filter(p1 -> p1.equals(zClass)).count() >= 1)
			throw new SingletonInterceptException(zClass);
		zhangQi.add(zClass);
	}

}
